﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;

namespace NJT.Services
{
    public static class 鼠标
    {
        private static int 点击次数 = 0;

        private static DispatcherTimer t;
        public static bool 双击检测()
        {
            点击次数 += 1;
            if (t == null)
            {
                t = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 500) };

                t.Tick += (o, e) =>
                {
                    t.IsEnabled = false;
                    点击次数 = 0;
                };
            }

            t.IsEnabled = true;
            if (点击次数 % 2 == 0)
            {
                t.IsEnabled = false;
                点击次数 = 0;
                return true;
            }
            return false;
        }
    }
}
